<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/activity.php');
require_once ('../lib/test.php');
require_once ('f:\wamp\www\simpletest\autorun.php');
require_once ('../lib/init.php');

class TestTemplate extends UnitTestCase {
    
    function setUp(){
        global $login_button;
        try{
        $me = getOneself();
        }catch(Exception $e){
            print($login_button);
            exit();
        }
    }
    
    //refer to http://www.simpletest.org/en/unit_test_documentation.html
    function testGetFriendPostActivities(){ 

                     
        //sample data from var_export
        $data =     array (
        'name' => 'friendPostQuery',
        'fql_result_set' => 
            array (
              0 => 
              array (
                'post_id' => '1246727707_1734969454508',
                'actor_id' => '612139051',
                'message' => 'Minkyu, you wanna do testing? What about missing the deadline n handing it in in april? Ask supervisor as ur putting too much pressure on urself..',
                'created_time' => '1289481160',
              ),
              1 => 
              array (
                'post_id' => '1246727707_1664226525979',
                'actor_id' => '612139051',
                'message' => 'Congrats on getting settled and back to the grindstone as they say. Did you by any chance come across how to use composite keys for DBs in android. There is little to no examples on the web :/',
                'created_time' => '1285605734',
              ),
              2 => 
              array (
                'post_id' => '1246727707_1602446861526',
                'actor_id' => '612139051',
                'message' => 'Hey Minkyu, you know the swiping motion through a carousel of items on the iphone? Did u come across how to do this in android without using ViewSwitcher/ViewFlipper? These methods are not v smooth in comparison. Any posts i\'ve read havent been positive..',
                'created_time' => '1281707935',
              ),
              3 => 
              array (
                'post_id' => '1246727707_1514471502197',
                'actor_id' => '612139051',
                'message' => 'Anyoung!',
                'created_time' => '1275511483',
              ),
              4 => 
              array (
                'post_id' => '1246727707_1372936163902',
                'actor_id' => '612139051',
                'message' => 'Minkyu dictaphones are only 15 pounds. Maybe a good idea to get one and I\'ll fill it up with me reading stuff so you can get pronounciation?? If you want of course :)',
                'created_time' => '1264679504',
              )
            )
        );
        
        $id = 612139051;
        $activities = array();
        $activities = getFriendPostActivities($data, $activities);
        
        $this->assertTrue(is_array($activities));
        $this->assertTrue(count($activities) == 5);
        
        
        print_r($activities);
    }
    
    function testRealData(){
        $id = 612139051;
        $data = getActivities($id);
        $friendPost = getResultSet('friendPostQuery', $data);
        $activities = array();
        $activities = getFriendPostActivities($friendPost, $activities);
        
        $friendPost = $friendPost['fql_result_set'];
        
        $this->assertTrue(is_array($activities));
        $this->assertEqual(count($friendPost), count($activities));
        print_r($activities);
    }
}
?>